package com.how2j.springcloud.controller;

import com.how2j.springcloud.pojo.Product;
import com.how2j.springcloud.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author: kaiyi
 * @create: 2020-10-23 23:49
 */
@Controller
public class ProductController {

  @Autowired
  ProductService productService;

  @RequestMapping("/products")
  public Object products(Model m) {
    List<Product> ps = productService.listProducts();
    m.addAttribute("ps", ps);
    return "products";
  }

}
